<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

	<ui:composition 
	  xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      template="/view/templates/templateLayout.xhtml">
      
      <ui:define name="conteudo">      	
  	  <link rel="stylesheet" type="text/css" href="./estilos.css"/>
  	  
<h:form id="formManterPlano" prependId="false">  
	<p:panel id="panelManterPlano" header="Manter Plano" style="margin-bottom:20px; ">  
	<f:facet name="header">
		<h:outputText value="Manter Plano" styleClass="outputTextTitulo"/>
	</f:facet>
 	<p:messages id="messages" autoUpdate="true" closable="true" /> 
    	<h:panelGrid id="pgPlano" columns="2" style="margin-top:20px; margin-right:10%;">  
            <h:outputLabel value="Código" styleClass="outputLabel"/>  
            <h:outputLabel value="Plano*" styleClass="outputLabel"/>             
            <p:inputText value="#{planoBean.plano.idPlano}" styleClass="inputId" disabled="true"/>  
  			<p:inputText value="#{planoBean.plano.descricao}"  styleClass="inputDescricao" />  
        </h:panelGrid> 
        <h:panelGrid id="pgPeriodo" columns="4" style="margin-right:10%;">  
            <h:outputLabel value="Código" styleClass="outputLabel"/>  
            <h:outputLabel value="Período*" styleClass="outputLabel"/>  
            <h:outputLabel value="Meses*" styleClass="outputLabel"/>    
            <h:outputLabel  />           
            <p:inputText value="#{planoBean.plano.periodo.idPeriodo}" styleClass="inputId" />  
  			<p:inputText value="#{planoBean.plano.periodo.descricao}"  styleClass="inputDescricao" />  
  			<p:inputText value="#{planoBean.plano.periodo.meses}" styleClass="inputId"/>
  			<p:commandButton icon="ui-icon-search" actionListener="#{planoBean.openDialogConsultarPeriodo}" immediate="true"/>
        </h:panelGrid>   
        <h:panelGrid id="pgCondicaoPagamento" columns="3" style="margin-right:10%;">  
            <h:outputLabel value="Código" styleClass="outputLabel"/>  
            <h:outputLabel value="Condição de Pagamento*" styleClass="outputLabel"/>      
            <h:outputLabel  />       
            <p:inputText value="#{planoBean.plano.condicaoPagamento.idCondicaoPagamento}" styleClass="inputId" disabled="true"/>  
  			<p:inputText value="#{planoBean.plano.condicaoPagamento.descricao}"  styleClass="inputDescricao"/>  
  			<p:commandButton icon="ui-icon-search" actionListener="#{planoBean.openDialogConsultarCondicaoPagamento}" immediate="true"/>
        </h:panelGrid>  
        
        <h:panelGrid id="pgPlanoModalidade" columns="6" style="margin-right:10%;">  
            <h:outputLabel value="Código" styleClass="outputLabel"/>  
            <h:outputLabel value="Modalidade*" styleClass="outputLabel"/>  
            <h:outputLabel  value="Valor (R$)*" styleClass="outputLabel"/>
            <h:outputLabel  />
            <h:outputLabel  />
            <h:outputLabel  />
            <p:inputMask  value="#{planoBean.planoModalidade.modalidade.idModalidade}" styleClass="inputId" />  
  			<p:inputText value="#{planoBean.planoModalidade.modalidade.descricao}" styleClass="inputDescricao" />  
  			<p:inputMask  value="#{planoBean.planoModalidade.valor}" styleClass="inputId" />  
  			<p:commandButton  icon="ui-icon-search" actionListener="#{planoBean.openDialogConsultarModalidade}" immediate="true" />
  			<p:commandButton icon="ui-icon-circle-plus" action="#{planoBean.addModalidade}" update="messages"/>
  			<p:commandButton value="Limpar"  immediate="true"/>
        </h:panelGrid> 
        
        <p:dataTable  id="tablePlanoModalidade" value="#{planoBean.arrayPlanoModalidade}" var="planoModalidade" style="margin-top:30px; width:40%"  
        				rowKey="#{planoModalidade}" selection="#{planoBean.planoModalidadeSelect}" >
			<p:column>
				<f:facet name="header">
					<h:outputText value="Modalidade" />
				</f:facet>
				<h:outputText value="#{planoModalidade.modalidade.descricao}" />
			</p:column>
			<p:column>
				<f:facet name="header">
					<h:outputText value="Valor" />
				</f:facet>
				<h:outputText value="#{planoModalidade.valor}" />
			</p:column>

       	 	<p:column style="width:4%">  
        		<f:facet name="header">
        	 		<h:outputText value="Excluir" />
        		</f:facet>
         		<p:commandButton icon="ui-icon-pencil" title="Remover"  immediate="true">
         			<f:setPropertyActionListener target="#{planoBean.planoModalidadeSelect}" value="#{planoModalidade}" />
         		</p:commandButton>
       	 	</p:column > 	
       	 	<f:facet name="footer" >
       	 		<h:outputText value="Total = #{planoBean.plano.total}" >
       	 			
       	 		</h:outputText>
       	 	</f:facet>        
        </p:dataTable>

    </p:panel>  
    <p:commandButton value="Salvar" actionListener="#{planoBean.savePlano}" update="panelManterPlano" style="margin-right:20px; margin-left:10px;" /> 
	<p:commandButton value="Voltar" action="#{planoBean.consultarPlano}" immediate="true" style="margin-right:20px;" /> 
</h:form>  	
<ui:include src="/view/plano/dialogConsultarModalidade.xhtml"></ui:include>
<ui:include src="/view/plano/dialogConsultarPeriodo.xhtml"></ui:include>
<ui:include src="/view/plano/dialogConsultarCondicaoPagamento.xhtml"></ui:include>


</ui:define>
</ui:composition>
